import requests
import json

# 执行API调用并存储响应
API调用并存储响应
url = 'https://hacker-news.firebaseio.com/v0/item/19155826.json'
r = requests.get(url)
print(f"Status code: {r.status_code}") 
# 将API响应存储在一个变量中
response_dict = r.json()
readable_file = 'data/readable_hn_data.json'
with open(readable_file, 'w') as f:
    json.dump(response_dict, f, indent=4)
# 处理结果
print(f"\nKeys: {len(response_dict)}")
for key in sorted(response_dict.keys()):
    print(key)
# 处理结果
print(f"\nKeys: {len(response_dict)}")
for key in sorted(response_dict.keys()):
    print(key)
